<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	System.out.println(basePath);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
		<title>优个网_登录</title>
		<meta charset="utf-8">
		
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/login.css">
	
	</head>
 <body>
	<header id="header">
		<img src="img/logo_dl.jpg">
	</header>
	<div id="banner">
		<img src="img/biaoshi1.jpg">
	</div>
	<div class="section">
		<div class="login">
			<p>
				<span style="margin-right:85px;">登录优个网，尽享运动精彩！</span>
				<a href="${pageContext.request.contextPath}/regist.tq" target="_block">注册有惊喜</a>
			</p>
			<form id="formLogin" action="${pageContext.request.contextPath}/checkLogin.tq" method=post>
			<ul>
				<li style="position: relative;">
					<p id="uname_p" style="font-size:14px; font-family:'宋体';background-color:#cd0000;color:#fff; width: 180px;padding:5px;margin-bottom: 5px;position:absolute;left: 0px;top:-26px;display: none;">验证码输入错误 请重新输入</p>
					<input name="uname" id="uname" placeholder="用户名" class="login_input bg_img1" type="text">
				</li>
				<li>
					<input name="pwd" id="upwd" placeholder="请输入密码" class="login_input bg_img2" type="password">
				</li>
				<li style="position: relative;">
					<input name="yzm" id="yzm" placeholder="请输入验证码" value="" class="yanzhengma" style="width: 112px; height: 22px;" type="text">
					<!--<img id="yzmimg" src="img/fff.jpg">-->
					<p id="checkCode_p" style="font-size:14px; font-family:'宋体';background-color:#cd0000;color:#fff; width: 180px;padding:5px;margin-bottom: 5px;position:absolute;left: 0px;top:-19px;display: none;">验证码输入错误 请重新输入</p>
					<canvas id="can" width="100" height="25" style="background-color: #dddddd;position:relative;top: 8px;left: 1px;"></canvas>
					<span id="can_span" style="line-height:34px; cursor:pointer;">看不清楚换一张</span>
				</li>
				<li>
					<input name="remember" value="1" style="float:left; margin-right:5px; margin-top:2px;" type="checkbox">
					<span >下次自动登录</span>
					<a href="/getpwd.php" style="margin-left:155px;">忘记密码</a>
				</li>
				<li>
					<input id="btn" class="dl_btn" value="登录" type="button">
				</li>
			</ul>
			</form>
		</div>
	</div>
	
		<div id="link">
			<a href="${basePath}/index/youge.tq" target="_block">首页</a>|<a href="#">关于我们</a>|<a href="#">联系我们</a>|<a href="#">加入优个网</a>|<a href="#">友情链接</a>|<a href="#">网站地图</a>|<a href="#">校园代理</a>|<a href="#">代理查询</a>|<a href="#">手机优个</a>|<a href="#">热销型号</a>|<a href="#">商品大全</a>|<a href="#">资讯主题</a>|<a href="#">商品主题</a>
		</div>
	<script src="js/jquery-1.11.3.js"></script>
	<script src="js/login.js"></script>
	
	<script type="text/javascript">
	var result=aa();
	$("#can_span").click(function(){
	  result=aa();
	});
	console.log(result);
	$("#uname").blur(function(){
		  var r=$(this).val();
		  if(r=="" || r==" "){
		    //$("#uname_p").html("请输入有效信息！").css({color:"#e4393c",fontWeight:"bold"});
		    $("#uname_p").html("请输入有效信息").css({color:"#fff",fontWeight:"bold"}).css({display:"block"});
		    return;
		  }
		  $.ajax({
		    type:"post",
		    url:"${pageContext.request.contextPath}/blurLogin.tq",
		    data:"uname="+r,
		    success:function(res){
		      console.log(res);
		      if(res == "true"){
		        $("#uname_p").html("用户名不存在").css({color:"#fff",fontWeight:"bold"}).css({display:"block"});
		      }else{
		        $("#uname_p").css({display:"none"});
		      }
		    },
		    error:function(res){
		      alert(res);
		    }
		  })
		});
		$("#btn").click(function(){
			var code=$("#yzm").val();
			console.log(code);
			  if(code==result){
			    $("#checkCode_p").html("验证码输入正确").css({display:"block",backgroundColor:"rgb(0,205,0)"});
			    $("#formLogin").submit();
			  }else{
			    $("#checkCode_p").html("验证码输入错误 请重新输入").css({display:"block"});
			  }
			
			
			
		});
		
		
	</script>
	
	
 </body>
</html>